//
//  YXYLoginViewController.m
//  Topit
//
//  Created by dllo on 15/12/19.
//  Copyright © 2015年 YXY. All rights reserved.
//

#import "YXYLoginViewController.h"
#import "ResumeViewController.h"
@interface YXYLoginViewController ()

@end

@implementation YXYLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"登陆";
    
    [self setUpLoginView];
    // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.view nightMode];
}
- (void)setUpLoginView {
    UIButton *sinaButton = [UIButton buttonWithType:UIButtonTypeSystem];
    sinaButton.frame = CGRectMake(self.view.width / 2 - 100, 220, 200, 30);
    sinaButton.backgroundColor = [UIColor colorWithRed:160 / 256.0 green:238 / 256.0 blue:225 / 256.0 alpha:1];
    [sinaButton setTitle:@"新浪" forState:UIControlStateNormal];
    [sinaButton addTarget:self action:@selector(sinaDidPress:) forControlEvents:UIControlEventTouchUpInside];
    sinaButton.layer.masksToBounds = YES;
    sinaButton.layer.cornerRadius = 15;
    sinaButton.titleLabel.textAlignment = 1;
    [self.view addSubview:sinaButton];
    
//    UIButton *qqButton = [UIButton buttonWithType:UIButtonTypeSystem];
//    qqButton.frame = CGRectMake(self.view.width / 2 - 100, 320, 200, 30);
//    qqButton.backgroundColor = [UIColor colorWithRed:160 / 256.0 green:238 / 256.0 blue:225 / 256.0 alpha:1];
//    [qqButton setTitle:@"QQ" forState:UIControlStateNormal];
//    [qqButton addTarget:self action:@selector(qqDidPress:) forControlEvents:UIControlEventTouchUpInside];
//    qqButton.layer.masksToBounds = YES;
//    qqButton.layer.cornerRadius = 15;
//    qqButton.titleLabel.textAlignment = 1;
//    [self.view addSubview:qqButton];
    
//    UIButton *weixinButton = [UIButton buttonWithType:UIButtonTypeSystem];
//    weixinButton.frame = CGRectMake(self.view.width / 2 - 100, 420, 200, 30);
//    weixinButton.backgroundColor = [UIColor colorWithRed:160 / 256.0 green:238 / 256.0 blue:225 / 256.0 alpha:1];
//    [weixinButton setTitle:@"豆瓣" forState:UIControlStateNormal];
//    [weixinButton addTarget:self action:@selector(weixinDidPress:) forControlEvents:UIControlEventTouchUpInside];
//    weixinButton.layer.masksToBounds = YES;
//    weixinButton.layer.cornerRadius = 15;
//    weixinButton.titleLabel.textAlignment = 1;
//    [self.view addSubview:weixinButton];
    
}


- (void)sinaDidPress:(UIButton *)sender {
    UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina];
    
    snsPlatform.loginClickHandler(self,[UMSocialControllerService defaultControllerService],YES,^(UMSocialResponseEntity *response){
        
        //          获取微博用户名、uid、token等
        
        if (response.responseCode == UMSResponseCodeSuccess) {
            UMSocialAccountEntity *snsAccount = [[UMSocialAccountManager socialAccountDictionary] valueForKey:UMShareToSina];
            NSMutableDictionary *user = [NSMutableDictionary dictionaryWithObjectsAndKeys:snsAccount.userName, @"name", snsAccount.iconURL, @"image", nil];
            [[NSUserDefaults standardUserDefaults] setObject:user forKey:@"user"];
            [ProgressHUD showSuccess:@"登陆成功"];
            [self.navigationController popViewControllerAnimated:YES];
        }});
}

- (void)qqDidPress:(UIButton *)sender {
//    UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToQQ];
    
//    snsPlatform.loginClickHandler(self,[UMSocialControllerService defaultControllerService],YES,^(UMSocialResponseEntity *response){
//        if (response.responseCode == UMSResponseCodeSuccess) {
//            UMSocialAccountEntity *snsAccount = [[UMSocialAccountManager socialAccountDictionary] valueForKey:UMShareToQQ];
//            NSMutableDictionary *user = [NSMutableDictionary dictionaryWithObjectsAndKeys:snsAccount.userName, @"name", snsAccount.iconURL, @"image", nil];
//            [[NSUserDefaults standardUserDefaults] setObject:user forKey:@"user"];
//            [ProgressHUD showSuccess:@"登陆成功"];
//            [self.navigationController popViewControllerAnimated:YES];
//        }});
    [ProgressHUD showSuccess:@"功能暂未开放"];
}

//- (void)weixinDidPress:(UIButton *)sender {
//    UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToDouban];
//
//    snsPlatform.loginClickHandler(self,[UMSocialControllerService defaultControllerService],YES,^(UMSocialResponseEntity *response){
//        if (response.responseCode == UMSResponseCodeSuccess) {
//            UMSocialAccountEntity *snsAccount = [[UMSocialAccountManager socialAccountDictionary] valueForKey:UMShareToDouban];
//            NSMutableDictionary *user = [NSMutableDictionary dictionaryWithObjectsAndKeys:snsAccount.userName, @"name", snsAccount.iconURL, @"image", nil];
//            [[NSUserDefaults standardUserDefaults] setObject:user forKey:@"user"];
//            [ProgressHUD showSuccess:@"登陆成功"];
//            [self.navigationController popViewControllerAnimated:YES];
//        }});
//
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
